package domotica.server;

import javax.jws.WebService;
import domotica.house.manager.HouseManager;
import domotica.house.simulation.utils.PhysicVariableSimulator;

/**
 * Questa classe implementa il Template HouseManager, inizializzando le i componenti connessi e gli utenti permessi.
 */

@WebService
public class HouseManagerImpl extends HouseManager {

	public HouseManagerImpl(){
		super();
		this.initActuatorsSensors();
		this.initUsers();
	}
	
	protected void initActuatorsSensors() {
		
		PhysicVariableSimulator[] physicVarSimulators = new PhysicVariableSimulator[11];
		
		physicVarSimulators[0]=new PhysicVariableSimulator(0, 50, 24, 0.2);
		physicVarSimulators[1]=new PhysicVariableSimulator(0, 50, 24, 0.4);
		physicVarSimulators[2]=new PhysicVariableSimulator(0, 50, 24, 0.2);
		physicVarSimulators[3]=new PhysicVariableSimulator(0, 50, 24, 0.4);
		physicVarSimulators[4]=new PhysicVariableSimulator(0, 50, 24, 0.2);
		physicVarSimulators[5]=new PhysicVariableSimulator(0, 50, 24, 0.4);
		physicVarSimulators[6]=new PhysicVariableSimulator(0, 100, 50, 0.2);
		physicVarSimulators[7]=new PhysicVariableSimulator(0, 100, 50, 0.2);
		physicVarSimulators[8]=new PhysicVariableSimulator(0, 100, 50, 0.2);
		physicVarSimulators[9]=new PhysicVariableSimulator(0, 100, 50, 0.2);
		physicVarSimulators[10]=new PhysicVariableSimulator(0, 100, 50, 0.2);
		
		ConditionerSimulator[] conditionerSimulators = new ConditionerSimulator[6];
		GardenWatererSimulator[] gardenWatererSimulators = new GardenWatererSimulator[5];
		int i=0;
		
		for (i=0; i<6; i++){
			conditionerSimulators[i] = new ConditionerSimulator("Condizionatore stanza "+(i+1), "Temperatura stanza "+(i+1),physicVarSimulators[i]);
			conditionerSimulators[i].connect("localhost","8080");
			this.addActuatorSensor(conditionerSimulators[i]);
		}
		
		for (int j=i; j<11; j++){
			gardenWatererSimulators[j-6] = new GardenWatererSimulator("Irrigatore giardino "+(j+(1-6)), "Umidita' terreno "+(j+(1-6)),physicVarSimulators[j]);
			gardenWatererSimulators[j-6].connect("localhost","8080");
			this.addActuatorSensor(gardenWatererSimulators[j-6]);
		}
	}
	
	protected void initUsers() {
		this.addUser("root1","root");
		this.addUser("root2","root");
	}

}
